package design.patterns.mementomode.widedemo;

/**
 * @Desc:   客户端
 * @author: cww
 * @DateTime: 2020-06-13 15:02
 */

public class MainTest {
    private static Originator o = new Originator();
    private static Caretaker c = new Caretaker();
    public static void main(String[] args) {
        // 改变发起人对象的状态
        o.setState("On");
        // 创建备忘录对象，并将发起人对象的状态存储起来
        c.setMemento(o.createMemento());
        // 修改发起人对象的状态
        o.setState("Off");
        // 恢复发起人对象的状态
        o.restoreMemento(c.getMemento());
    }
}
